package reduce.fz.com.reduce.service.preference;

import java.util.prefs.PreferencesFactory;

import reduce.fz.com.reduce.bean.User;
import reduce.fz.com.reduce.constant.PreferenceConst;
import reduce.fz.com.reduce.util.base.PreferenceUtil;

/**
 * Created by qingshengzheng on 15/11/9.
 */
public class UserPreference {

    public static  void saveUser(User user)
    {
        PreferenceUtil.saveStringPreference(PreferenceConst.KEY_MOBILE, user.mobile);
        PreferenceUtil.saveStringPreference(PreferenceConst.KEY_PASSWORD,user.password);
        PreferenceUtil.saveStringPreference(PreferenceConst.KEY_NICKNAME, user.nickname);
        PreferenceUtil.saveLongPreference(PreferenceConst.KEY_UID, user.uid);
    }

    public static User getUser()
    {
        String mobile=PreferenceUtil.getStringPreference(PreferenceConst.KEY_MOBILE);
        String password=PreferenceUtil.getStringPreference(PreferenceConst.KEY_PASSWORD);
        String nickname=PreferenceUtil.getStringPreference(PreferenceConst.KEY_NICKNAME);
        Long uid=PreferenceUtil.getLongPreferences(PreferenceConst.KEY_UID,0);
        User user=new User();
        user.mobile=mobile;
        user.password=password;
        user.nickname=nickname;
        user.uid=uid;
        return user;
    }


}
